
/**
 * Handle record selected.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"443394C1-5BC6-4A4E-8207-BC963C54CEBA"}
 */
function onRecordSelection(event) {
	elements.fld_valor_int.visible = false
	elements.fld_valor_num.visible = false
	elements.fld_valor_txt.visible = false
	elements.fld_valor_vl.visible = false
	switch( tipo )
	{
		case 1:
		{
			elements.fld_valor_txt.visible = true
			break;
		}
		case 2:
		{
			if (valuelist)
			{
				var $valores = application.getValueListItems(valuelist)
				application.setValueListItems('param_usr_valores_vl', $valores)
				elements.fld_valor_vl.visible = true
			}
			else
			{
				elements.fld_valor_int.visible = true
			}
			break;
		}
		case 3:
		{
			elements.fld_valor_num.visible = true
			break;
		}
	}
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"AC8EBECA-B5CD-454C-85AA-DD3D34E31E04"}
 */
function onShow(firstShow, event) {
	databaseManager.setAutoSave(false)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"AD607BC7-4D7C-432C-B270-7F168B7EFB45"}
 */
function confirmar(event) {
	if (databaseManager.saveData())
	{
		var $valor
		switch( tipo )
		{
			case 1:
			{
				$valor = valor_txt
				break;
			}
			case 2:
			{
				$valor = valor_int
				break;
			}
			case 3:
			{
				$valor = valor_num
				break;
			}
		}
		globals[nombre_var] = $valor
	}
	else
	{
		globals.DIALOGS.showWarningDialog('Aviso','Ocurrió un error al modificar la variable','OK')
	}
	cerrar()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"5A0FF9B1-14C1-4535-9DD1-8A257B7F2787"}
 */
function cancelar(event) {
	databaseManager.revertEditedRecords()
	cerrar()
}

/**
 * @properties={typeid:24,uuid:"ADD88C6F-2296-4644-B80D-3BB23D6E53B1"}
 */
function cerrar()
{
	var $win = application.getWindow('PARAM_USR')
	$win.hide()
	$win.destroy()
}
/**
 * Handle hide window.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"F39EC37A-3B12-480F-83F6-1E8B0F0CB0EA"}
 */
function onHide(event) {
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	return true
}
